DXL dummyItem zDummy

Hi!

I'm trying to find out what the following script does, the only problem is it has a part with a so called dummyItem which I've never seen before. This is the part of the script where I've found the `dummyItem`

   

bool doExpandDirectory(DBE db, string sTreeEntry)
    {
    int    numSubDirs      = 0
    string s               = ""
    string sDummyEntry     = ""
    string sDirectory      = ""
    string f               = ""
    string sNewTreeEntry   = ""
    string sNewDummyEntry  = ""
    string sDriveIsEmpty   = ""
    string sErrMsg         = ""
    string sFullPath       = ""
    Stat   fStat           = null

    // convert backslashes
    sDirectory = convertToBackSlashes(sTreeEntry)

    sDummyEntry = sTreeEntry "/" dummyItem   


convertToBackSlashes is an already existing part we defined earlier.
The main problem is that I can't find anywhere what the `dummyItem` is. There is no `#include` in the begining, there is no other example for the `dummyItem` anywhere.

The only lead I have is that I've tried a simple code with:

    string asd
    asd = dummyItem
    print asd
And the result was:
`zDummy`

I know for sure that it's not a variable, since it would be something like `sDummyItem`

If anyone has any idea what this is, I'd be really glad.


CAJ69I - Fri Jun 17 10:03:12 EDT 2016

Re: DXL dummyItem zDummy
O.Wilkop - Fri Jun 17 14:34:44 EDT 2016

I'm pretty sure it's just a (global) string variable. But let me explain the code you are probably looking at:

 

The function you are looking at is the "doExpand" function for a treeView element of the gui. When you look at a treeView, like the database explorer for example, you will see that every not empty folder has a little plus sign next to it to expand the tree further. This function, once attached to a treeView will trigger everytime someone clicks the little plus icon - the sTreeEntry parameter is the path of the treeView item that shall be expanded, and the return value (true or false) decides whether the treeView should be expanded or not.

 

The variables defined in your snippet lead me to believe that you are looking at a treeView of some kind of filesystem ("sDriveIsEmpty" and "fStat"). If you wanted to fill a treeView with all directories of your current harddrive, you'd have to loop through all files and folders first and add each of them one by one to the treeView. This would take a huge amount of time before the treeView is filled (several minutes) and would get even worse if you consider network drives etc. To prevent these huge loading times, the developer of your snippet uses a trick to only load what is absolutely needed, and add the remaining paths/files on demand.

 

This is how he does it:

1. Create treeView

2. Add (for example) the path "C:" and "D" to the treeView

3. Add "C:/"dummyItem" and "D:/"dummyItem to the treeView

4. Add the "doExpandDirectory" function above

 

This will create a treeView with C: and D:, and since you added the dummyItems, both C: and D: will have the little + icon next to them. As soon as you click the + icon, the function above triggers, deletes the dummyItem (line 18, sDummyEntry) from the treeView and then adds all the files and folders that are actually in C:/. Important here is that for every folder he will add another "C:/folder/"dummyItem, so that the folder again gets the little + icon next to it (and therefore can be expanded).

 

This way you will only load the data that is absolutely needed and load the new folder and files on demand, exactly when they are needed. Should a folder not have any files in it after expanding, the little + icon will just disappear (since the function above always deletes the dummyItem from the treeView).

 

 

I hope that explanation helped, tell me if anything is unclear.

Re: DXL dummyItem zDummy
Mike.Scharnow - Sat Jun 18 07:33:24 EDT 2016

in Additon to O.Wilkop's excellent explanation: "dummyItem" is indeed a string variable. It is declared somewhere in the DXL code that belongs to DOORS itself.

 

Your statement "I know for sure that it's not a variable, since it would be something like `sDummyItem`" is not correct. If a variable begins with s to indicate that it is of type string, that is just a naming convention (in this case derived from the hungarian notation). Usage of naming conventions is nowhere enforced. Very often you find code where the developers stick to a naming convention in one part of the code, and neglect it in another part of the code. E.g. your function has a variable "string f".

Re: DXL dummyItem zDummy
CAJ69I - Mon Jun 20 03:07:44 EDT 2016

Thank you both very much, it's clear to me now.